<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class SStuCollectInfo extends Model
{
    //

    use SoftDeletes;
    public $table = "s_stu_collect_info";

    protected $fillable = [
        'user_id', 'teacher_id', 'created_at', 'updated_at'
    ];

    public function users()
    {
        return $this->belongsTo('App\User', 'user_id');
    }

    public function teachers()
    {
        return $this->belongsTo('App\Models\STeacherInfo', 'teacher_id');
    }

    static public function getUserTeachers($user_id, $start=0, $limit=10)
    {
        return self::leftJoin('s_teacher_info as t', 's_stu_collect_info.teacher_id', 't.id')
                    ->where('s_stu_collect_info.user_id', $user_id)
                    ->select('t.headimg', 't.name', 't.certification_zh_cn', 't.tags_zh_cn')
                    ->offset($start)
                    ->limit($limit)
                    ->get();
    }
}
